package com.bluej.redis.demo;

import java.util.Date;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.bluej.redis.tools.RedisUtil;
import com.bluej.redis.tools.RedisUtil2;

public class Start {
	static boolean  flag =true;

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		ApplicationContext ac = new ClassPathXmlApplicationContext(new String[]{"springConfig.xml"});
        //从Spring容器中根据bean的id取出我们要使用的redisUtil对象
		
		RedisUtil redisUtil =ac.getBean("redisUtil", RedisUtil.class);
		int a=1;
		
		while(flag){
			redisUtil.set("mykey", new Date());
			sl();
			String value =redisUtil.get("mykey").toString();
			System.out.println(value);
			System.out.println(a);
			if(a++==2){
				break;
			}
		}
		
		
	}

	public static void sl(){
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
